package chapter7.section2;

//程序7-5：Java 9中try-with-resources用法

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.Comparator;

public class TryWithRes {
	public static void main(String[] args) throws IOException {
		System.out.println(readData("test"));
	}

	static String readData(String message) throws IOException {

		Comparator<Float> cm = (x, y) -> {
			return Float.compare(x, y);
		};

		Reader inputString = new StringReader(message);
		BufferedReader br = new BufferedReader(inputString);
		try (br) {
			return br.readLine();
		}
	}
}
